#
# Makefile, Makefile.in
# Makefiles for the Customizer Utility of the Protea Project
# Copyright (C) 2008 Bruce A. James
#
# This file is part of the Protea Project.
#
# The Protea Project is free software; you can redistribute it and/or modify it 
# under the terms of the GNU General Public License as published by the 
# Free Software Foundation, either version 3 of the License, or (at your 
# option) any later version.
#
# The Protea Project is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# You should have received a copy of the GNU General Public License along 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
# Please send correspondence to:
#
# theproteaproject@gmail.com
#

PROGRAMS = customizer_base.trans customizer.trans customizer_pro.trans
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ @INTERNAL_FLAG@ @PICFLAG@ -D__REENTRANT
COMPILE = $(CXX) $(CXXFLAGS)
LIBS = @LIBS@ -L ../.. -lprotea$(TOOLSBASE)

LDFLAGS=@LDFLAGS@ @PICFLAG@
LINK=$(CXX) $(LDFLAGS)

PRO_SRCS := $(wildcard pro/*.cpp)
PRO_OBJS := $(patsubst %.cpp,%.o,$(PRO_SRCS))
PRO_DEPS := $(patsubst %.cpp,%.d,$(PRO_SRCS))

NORMAL_SRCS := $(wildcard normal/*.cpp)
NORMAL_OBJS := $(patsubst %.cpp,%.o,$(NORMAL_SRCS))
NORMAL_DEPS := $(patsubst %.cpp,%.d,$(NORMAL_SRCS))

BASE_SRCS := $(wildcard base/*.cpp)
BASE_OBJS := $(patsubst %.cpp,%.o,$(BASE_SRCS))
BASE_DEPS := $(patsubst %.cpp,%.d,$(BASE_SRCS))

INSTALL = /@INSTALL@

all : $(PROGRAMS)

install:
	@echo "Installing customizer components"
	@$(INSTALL) -d $(XSIROOT)/Tools/CUSTOMIZER
	@$(INSTALL) $(PROGRAMS) $(XSIROOT)/Tools/CUSTOMIZER

clean :
	-rm $(PROGRAMS) $(BASE_OBJS) $(NORMAL_OBJS) $(PRO_OBJS) $(BASE_DEPS) $(NORMAL_DEPS) $(PRO_DEPS)

%.d: %.cpp
	@echo Compiling dependency: $*.d
	@set -e; g++ -MM -I$(XERCESCROOT)/include $< \
	| sed 's|$*.o:|$*.o $*.d:|g' > $@; \
	[ -s $@ ] || rm -f $@

%.o: %.cpp %.d
	@echo "Compiling source file: $*.cpp"
	@set -e; $(COMPILE) -o $@ -c $<

customizer.trans : $(NORMAL_OBJS)
	@echo "Link Customizer"
	@set -e; $(LINK) @LDSHFLAGS@ -o $@ $(LIBS) $(NORMAL_OBJS)

customizer_pro.trans : $(PRO_OBJS)
	@echo "Link Customizer Pro"
	@set -e; $(LINK) @LDSHFLAGS@ -o $@ $(LIBS) $(PRO_OBJS)

customizer_base.trans : $(BASE_OBJS)
	@echo "Link Customizer Base"
	@set -e; $(LINK) @LDSHFLAGS@ -o $@ $(LIBS) $(BASE_OBJS)

depend: $(BASE_DEPS) $(NORMAL_DEPS) $(PRO_DEPS)

-include $(BASE_DEPS) $(NORMAL_DEPS) $(PRO_DEPS)

